<?php
defined('IN_ADMIN') or exit('No permission resources.');
include $this->admin_tpl('header','admin');
?>
<?php 
    $relationIds = '';
    if(!empty($catesInfo)){
        foreach ($catesInfo as $k=>$v){
            $relationIds .= '|v'.$v['catid'];
        }
    }?>
<div class="pad-10">
<input type="hidden" value="content" name="m">
<input type="hidden" value="content" name="c">
<input type="hidden" value="public_relationlist" name="a">
<input type="hidden" value="<?php echo $modelid;?>" name="modelid">
<input type="hidden" value="<?php if (strlen($relationIds)>0){echo $relationIds;}?>" name="relation" id="relation">
<fieldset>
	<legend>一级栏目</legend>
<?php
	foreach($catelist as $_v) {
		$checked = $_v['catid']==34 ? 'checked' : '';
		echo "<label class='ib' style='width:128px'><input type='radio' name='select_siteid' $checked onclick='change_siteid(".$_v['catid'].")'> " .$_v['catname']."</label>";

	}
?>
</fieldset>
    <div style="width:500px; padding:2px; border:1px solid #d8d8d8; float:left; margin-top:10px; margin-right:10px; overflow:hidden">
    <table width="100%" cellspacing="0" class="table-list" >
            <thead>
                <tr>
                <th width="100"><?php echo L('catid');?></th>
                <th ><?php echo L('catname');?></th>
                <th width="150" ><?php echo L('select_model_name');?></th>
                </tr>
            </thead>
        <tbody id="load_catgory">
        <?php echo $categorys;?>
        </tbody>
        </table>
    </div>

    <div style="overflow:hidden;_float:left;margin-top:10px;*margin-top:0;_margin-top:0; width:144px">
    <fieldset>
        <legend><?php echo L('category_checked');?></legend>
    <ul class='list-dot-othors' id='catname'>
        <?php if(!empty($catesInfo)){?>
            <?php foreach ($catesInfo as $key=>$value){?>
            <li id='v<?php echo $value['catid']?>'>·<input type='hidden' name='othor_catid[]' value='<?php echo $value['catid']?>'><span><?php echo $value['catname']?></span><a href='javascript:;' class='close' onclick="remove_id('<?php echo 'v'.$value['catid']?>')"></a></li>
            <?php }?>
        <?php }?>
    </ul>
    </fieldset>
    </div>
</div>
<style type="text/css">
.line_ff9966,.line_ff9966:hover td{background-color:#FF9966}
.line_fbffe4,.line_fbffe4:hover td {background-color:#fbffe4}
.list-dot-othors li{float:none; width:auto}
</style>
<SCRIPT LANGUAGE="JavaScript">
<!--
	function select_list(obj,title,id) {
		var flag_sids = $('#relation').val();
		var sid = 'v'+id;
		if (flag_sids.indexOf(sid) > 0){
			alert('该栏目已选择');return false;
		}
		flag_sids += '|'+sid;
		$('#relation').val(flag_sids);
		$(obj).attr('class','line_fbffe4');
		var str = "<li id='"+sid+"'>·<input type='hidden' name='othor_catid[]' value='"+id+"'><span>"+title+"</span><a href='javascript:;' class='close' onclick=\"remove_id('"+sid+"')\"></a></li>";
		window.parent.$('#add_othors_text').append(str);
		$('#catname').append(str);
}

function change_siteid(cateid) {
		$("#load_catgory").load("?m=content&c=content&a=public_getcate_categorys&siteid=<?php echo $siteid;?>&cateid="+cateid);
}
//移除ID
function remove_id(id) {
	$('#'+id).remove();
	window.parent.$('#'+id).remove();
	var flag_sids = $('#relation').val();
	flag_sids = flag_sids.replace(id,'');
	$('#relation').val(flag_sids);
}
change_siteid(34);
//-->
</SCRIPT>
</body>
</html>